package com.ruangong.GitClient.HunHePanAPI;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.List;
import com.ruangong.GitClient.R;
import com.ruangong.GitClient.HunHePanAPI.MovieLink;
public class MovieLinkAdapter extends ArrayAdapter<MovieLink> {

    private Context context;
    private List<MovieLink> movieLinks;

    public MovieLinkAdapter(Context context, List<MovieLink> movieLinks) {
        super(context, 0, movieLinks);
        this.context = context;
        this.movieLinks = movieLinks;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View listItem = convertView;
        if (listItem == null) {
            listItem = LayoutInflater.from(context).inflate(R.layout.movie_link_item, parent, false);
        }

        MovieLink currentMovieLink = movieLinks.get(position);

        TextView disknameTextView = listItem.findViewById(R.id.disknameTextView);
        String diskname = android.text.Html.fromHtml(currentMovieLink.getDiskName()).toString();
        disknameTextView.setText(diskname);

        return listItem;
    }
}
